#include "Token.h"

namespace MiniDB
{

    // TokenType到字符串的映射
    std::unordered_map<TokenType, std::string> tokenTypeNames = {
        {TokenType::SELECT, "SELECT"},
        {TokenType::FROM, "FROM"},
        {TokenType::WHERE, "WHERE"},
        {TokenType::INSERT, "INSERT"},
        {TokenType::INTO, "INTO"},
        {TokenType::VALUES, "VALUES"},
        {TokenType::UPDATE, "UPDATE"},
        {TokenType::SET, "SET"},
        {TokenType::DELETE, "DELETE"},
        {TokenType::CREATE, "CREATE"},
        {TokenType::TABLE, "TABLE"},
        {TokenType::DROP, "DROP"},
        {TokenType::ALTER, "ALTER"},
        {TokenType::ADD, "ADD"},
        {TokenType::COLUMN, "COLUMN"},
        {TokenType::DATABASE, "DATABASE"},
        {TokenType::USE, "USE"},
        {TokenType::SHOW, "SHOW"},
        {TokenType::TABLES, "TABLES"},
        {TokenType::DESCRIBE, "DESCRIBE"},
        {TokenType::BEGIN, "BEGIN"},
        {TokenType::COMMIT, "COMMIT"},
        {TokenType::ROLLBACK, "ROLLBACK"},
        {TokenType::TRANSACTION, "TRANSACTION"},
        {TokenType::PRIMARY, "PRIMARY"},
        {TokenType::KEY, "KEY"},
        {TokenType::NOT, "NOT"},
        {TokenType::NULL_TOKEN, "NULL"},
        {TokenType::INT, "INT"},
        {TokenType::VARCHAR, "VARCHAR"},
        {TokenType::FLOAT, "FLOAT"},
        {TokenType::BOOLEAN, "BOOLEAN"},
        {TokenType::DATE, "DATE"},
        {TokenType::TEXT, "TEXT"},
        {TokenType::EQUALS, "="},
        {TokenType::NOT_EQUALS, "!="},
        {TokenType::GREATER, ">"},
        {TokenType::LESS, "<"},
        {TokenType::GREATER_EQUALS, ">="},
        {TokenType::LESS_EQUALS, "<="},
        {TokenType::AND, "AND"},
        {TokenType::OR, "OR"},
        {TokenType::LIKE, "LIKE"},
        {TokenType::IN, "IN"},
        {TokenType::BETWEEN, "BETWEEN"},
        {TokenType::IS, "IS"},
        {TokenType::COMMA, ","},
        {TokenType::SEMICOLON, ";"},
        {TokenType::LPAREN, "("},
        {TokenType::RPAREN, ")"},
        {TokenType::DOT, "."},
        {TokenType::STAR, "*"},
        {TokenType::IDENTIFIER, "IDENTIFIER"},
        {TokenType::STRING_LITERAL, "STRING_LITERAL"},
        {TokenType::NUMBER_LITERAL, "NUMBER_LITERAL"},
        {TokenType::EOF_TOKEN, "EOF"}};

    std::string Token::toString() const
    {
        return "Token(" + tokenTypeNames[type] + ", '" + value + "', line=" +
               std::to_string(line) + ", col=" + std::to_string(column) + ")";
    }

} // namespace MiniDB
